home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 4
/
Apprentice-Release4.iso
/
Languages
/
Mops 2.7
/
Mops ƒ
/
PathsMod.txt
< prev
next >
Wrap
Text File
|
1995-07-05
|
2KB
|
74 lines
\ We call this module if a list of HFS path designators is to be used to
\ find a file. First we grab the file with the list
\ of path designators (one per line). For each designator we prepend
\ it to the given filename, and attempt to open the file. We keep
\ going until either the open succeeds or we run out of path designators.
\ If the open succeeds we leave the name in the fcb set to the full
\ path name. If the open fails we restore the name to what it was.
objPtr PATHS_F class_is file
objHandle PATHS_HDL
string NAME
string FULLNAME
string PDS
local OWP { fcb mode \ ret? -- rc }
: OPENLOOP
BEGIN \ Loop over path designators
len: pds
NIF \ Not found
all: name fcb name: file \ Restore orig name
FNF EXIT
THEN
RET chsearch: pds -> ret?
pds ->: fullName name $add: fullName
all: fullName fcb name: file
fcb mode (open) NIF 0 EXIT THEN \ Found
step: pds ret? negate skip: pds
AGAIN ;
:loc OWP
reset: pds
len: pds NIF FNF EXIT THEN
\ If no paths, we return a "file not found" error.
getName: [ fcb ]
put: name new: fullName
openLoop
release: name release: fullName ;loc
: GETPATHS \ ( addr len -- )
true -> use_paths? \ This becomes the default now
\ that GETPATHS has been called
keep: pathsMod
nil?: pds IF new: pds ELSE clear: pds THEN
release: paths_hdl ['] file newObj: paths_hdl
obj: paths_hdl -> paths_f
name: paths_f openReadOnly: paths_f
IF
msg# 133 \ Warning - couldn't find paths file
release: paths_hdl nilP -> paths_f EXIT
THEN
size: paths_f setsize: pds
all: pds read: paths_f drop
close: paths_f drop releaseObj: paths_hdl ;
: .PATHS { \ ret? -- }
nil?: pds ?EXIT
reset: pds
BEGIN
len: pds 0EXIT
RET chsearch: pds -> ret?
get: pds type cr
step: pds ret? negate skip: pds
AGAIN ;
: REL release: pds ;
' rel setRelease